#!/bin/bash
tar xf linux-5.5.3.tar.xz
cd linux-5.5.3
ARCH=x86_64
case $4 in
  aarch64*)
    ARCH=arm64;;
  alpha*)
    ARCH=alpha;;
  arc*)
    ARCH=arc;;
  arm*)
    ARCH=arm;;
  c6x*)
    ARCH=c6x;;
  csky*)
    ARCH=csky;;
  h8300*)
    ARCH=h8300;;
  hexagon*)
    ARCH=hexagon;;
  i386*)
    ARCH=x86;;
  ia64*)
    ARCH=ia64;;
  m68k*)
    ARCH=m68k;;
  microblaze*)
    ARCH=microblaze;;
  mips*)
    ARCH=mips;;
  nds32*)
    ARCH=nds32;;
  nios2*)
    ARCH=nios2;;
  openrisc*)
    ARCH=openrisc;;
  parisc*)
    ARCH=parisc;;
  powerpc*)
    ARCH=powerpc;;
  riscv*)
    ARCH=riscv;;
  s390*)
    ARCH=s390;;
  sh*)
    ARCH=sh;;
  sparc*)
    ARCH=sparc;;
  um*)
    ARCH=um;;
  unicore32*)
    ARCH=unicore32;;
  x86*)
    ARCH=x86;;
  xtensa*)
    ARCH=xtensa;;
  x86_64*)
    ARCH=x86;;
  *)
    ARCH=x86;;
esac
pwd
make ARCH=$ARCH mrproper -j$2
make ARCH=$ARCH headers -j$2
find usr/include -name '.*' -delete
rm usr/include/Makefile
cp -rv usr/include/* $1/usr/include
cd ..
rm -rf linux-5.5.3
